<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
      $(function() {
        $("#validForm").validate();
        $("input[name='name']").focus();
      });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optMulti(form, action, msg) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }

        function liveSave(form, action, msg) {
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>直播 - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>
<c:set var="numberExist"><s:message code="vote.number.exist"/></c:set>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post">
            <tags:search_params/>
            <f:hidden name="id" value="${bean.id}"/>
            <f:hidden name="stat" value="${stat}"/>
            <f:hidden name="position" value="${position}"/>
            <f:hidden name="wowzaType" value="${bean.wowzaType}"/>
            <input type="hidden" id="redirectLive" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:livebroadcast:create">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='create.do?stat=${stat}';"<c:if
                                    test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <%--<shiro:hasPermission name="ext:vote:copy">--%>
                        <%--<button class="btn btn-default" type="button" onclick="location.href='create.do?id=${bean.id}&${searchstring}';"<c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message code="copy"/></button>--%>
                        <%--</shiro:hasPermission>--%>
                        <shiro:hasPermission name="ext:livebroadcast:delete">
                            <button class="btn btn-default" type="button"
                                    onclick="if(confirmDelete()){location.href='delete.do?ids=${bean.id}&${searchstring}&stat=${stat}';}"
                                    <c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="delete"/></button>
                        </shiro:hasPermission>
                    </div>
                    <%--<div class="btn-group">--%>
                        <%--<button class="btn btn-default" type="button"--%>
                                <%--onclick="location.href='edit.do?id=${side.prev.id}&position=${position-1}&${searchstring}stat=${stat}';"--%>
                                <%--<c:if test="${empty side.prev}"> disabled="disabled"</c:if>><s:message--%>
                                <%--code="prev"/></button>--%>
                        <%--<button class="btn btn-default" type="button"--%>
                                <%--onclick="location.href='edit.do?id=${side.next.id}&position=${position+1}&${searchstring}stat=${stat}';"--%>
                                <%--<c:if test="${empty side.next}"> disabled="disabled"</c:if>><s:message--%>
                                <%--code="next"/></button>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <div class="btn-group">
                        <button class="btn btn-default" type="button"
                                onclick="location.href='list.do?${searchstring}&stat=${stat}';"><s:message
                                code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <div class="row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>直播标题</label>
                            <div class="col-sm-10">
                                <f:text name="title" value="${oprt=='edit' ? (bean.title) : ''}"
                                        class="form-control required" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>直播简介</label>
                            <div class="col-sm-10">
                                <f:textarea name="introduction" value="${bean.introduction}"
                                            class="form-control {maxlength:255} required" rows="5"/>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <%--<div class="form-group">--%>
                    <label class="col-sm-4 control-label"><em class="required">*</em><s:message
                            code="vote.status"/></label>
                    <div class="col-sm-8">
                        <select class="form-control" name="status" id="select_1" onclick="setTiemDateView()" >
                            <f:option value="0" selected="${bean.status}" default="0"><s:message
                                    code="live.0"/></f:option>
                            <f:option value="1" selected="${bean.status}"><s:message code="live.1"/></f:option>
                            <f:option value="2" selected="${bean.status}"><s:message code="live.2"/></f:option>
                        </select>
                    </div>
                    <%--</div>--%>
                </div>
                <script type="text/javascript">
                    function setTiemDateView() {
                        var status = $('#select_1').val();
                        /*if(status ==0){
                            $('#timeDateRoom').show();
                        }else{
                            $('#timeDateRoom').hide();
                        }*/
                        $('#timeDateRoom').show();
                    }
                    $(function(){
                        setTiemDateView();
                    })
                </script>

                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group" id="timeDateRoom" style="display: none;">
                            <label class="col-sm-4 control-label"><em class="required">*</em>开播时间</label>
                            <div class="col-sm-8">
                                <input type="text" name="time" value="<fmt:formatDate value="${bean.time}" pattern="yyyy-MM-dd'T'HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});" class="form-control required" style="padding-left:3px;padding-right:3px;"/>
                                <%--<input class="form-control" type="date" name="time" value="<fmt:formatDate value="${bean.time}" pattern="yyyy-MM-dd'T'HH:mm:ss"/>"--%>
                                       <%--onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});"/>--%>

                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><em class="required">*</em>直播封面</label>
                                <div class="col-sm-10">
                                    <script>
                                        function fn_smallImage(src) {
                                            Cms.scaleImg("img_smallImage", 200, 100, src);
                                        };
                                    </script>
                                    <div style="display:table;width:100%;">
                                        <div style="display:table-cell;vertical-align:middle;">
                                            <div class="input-group">
                                                <span class="input-group-addon">地址</span>
                                                <input type="text" id="smallImage" name="image" value="${bean.image}"
                                                       onchange="fn_smallImage(this.value);" class="form-control required">
                                            </div>
                                            <div class="form-inline" style="margin-top:3px;">
                                                <button class="btn btn-default" type="button" id="smallImageButton">选择
                                                </button>
                                                <object id="SWFUpload_0" type="application/x-shockwave-flash"
                                                        data="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304"
                                                        width="54" height="34" class="swfupload">
                                                    <param name="wmode" value="transparent">
                                                    <param name="movie"
                                                           value="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304">
                                                    <param name="quality" value="high">
                                                    <param name="allowScriptAccess" value="always">
                                                    <param name="flashvars"
                                                           value="movieName=SWFUpload_0&amp;uploadURL=%2Fcmscp%2Fcore%2Fupload_image.do%3Bjsessionid%3DB7EED2164EABD024D9BFE3361803971D%3F_site%3D&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=file&amp;fileTypes=*.*&amp;fileTypesDescription=Images&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=&amp;buttonWidth=54&amp;buttonHeight=34&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-100&amp;buttonDisabled=false&amp;buttonCursor=-2">
                                                </object>
                                                <button class="btn btn-default" type="button">上传</button>
                                                <button class="btn btn-default" type="button" id="smallImageSwfCancel"
                                                        onclick="smallImageSwfUpload.cancelQueue();" disabled="">取消
                                                </button>
                                            </div>
                                            <%--<div>--%>
                                                <%--<label class="checkbox-inline"><input type="checkbox" id="s_smallImage"--%>
                                                                                      <%--checked="checked">压缩</label>--%>
                                                <%--<label class="checkbox-inline"><input type="checkbox" id="e_smallImage">不按原图比例</label>--%>
                                                <%--<label class="checkbox-inline"><input type="checkbox"--%>
                                                                                      <%--id="wm_smallImage">水印</label>--%>
                                            <%--</div>--%>
                                            <input type="hidden" id="t_smallImage" value="false">
                                            <input type="hidden" id="tw_smallImage" value="116">
                                            <input type="hidden" id="th_smallImage" value="77">
                                        </div>
                                        <div style="width:200px;display:table-cell;vertical-align:middle;text-align:center;">
                                            <img id="img_smallImage" style="display:none;">
                                        </div>
                                    </div>
                                    <div id="smallImageSwfProgress"></div>
                                    <script>
                                        var smallImageSwfUpload = Cms.swfUploadImage("smallImage", {
                                            jsessionid: "B7EED2164EABD024D9BFE3361803971D",
                                            file_size_limit: "0",
                                            file_types: "*.*"
                                        });
                                        $(function () {
                                            Cms.f7.uploads("smallImage", "smallImage", {
                                                settings: {"title": "选择附件"},
                                                callbacks: {
                                                    "ok": function (src) {
                                                        fn_smallImage(src);
                                                    }
                                                }
                                            });
                                        });
                                        fn_smallImage("");
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6" style="display: none;">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required"></em>开关预约</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"><f:radio name="subscribe" value="0"
                                                                     checked="${bean.subscribe}"
                                                                     default="0"/>关闭预约</label>
                                <label class="radio-inline"><f:radio name="subscribe" value="1"
                                                                     checked="${bean.subscribe}"/>开启预约</label>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6" style="display: none;">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">开关评论</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"><f:radio name="review" value="0" checked="${bean.review}"  default="0"/> 关闭评论</label>
                                <label class="radio-inline"><f:radio name="review" value="1" checked="${bean.review}"/> 开启评论</label>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">点击量</label>
                            <div class="col-sm-10">
                                <f:text class="form-control digits" name="views" value="${bean.views}" maxlength="9" default="0"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>直播来源</label>
                            <div class="col-sm-10">
                                <c:if test="${empty bean.source}">
                                    <f:text name="source" value="${site.name}" class="form-control" maxlength="150"/>
                                </c:if>
                                <c:if test="${not empty bean.source}">
                                    <f:text name="source" value="${bean.source}" class="form-control" maxlength="150"/>
                                </c:if>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>主持人</label>
                            <div class="col-sm-10">
                                <f:text name="compere" value="${(bean.compere)}" class="form-control" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>推流地址</label>
                            <div class="col-sm-10">
                                <f:text name="taddress" value="${bean.taddress}" class="form-control" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>回看地址</label>
                            <%--<div class="col-sm-10">--%>
                                <%--<f:text name="fLookBack" value="${bean.fLookBack}" class="form-control"--%>
                                        <%--maxlength="150"/>--%>
                            <%--</div>--%>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <f:text class="form-control" id="fLookBack" name="fLookBack" value="${bean.fLookBack}" maxlength="255"/>
                                <span class="input-group-btn">
						      	  <button class="btn btn-default" id="fLookBackButton" type="button"><s:message code='choose'/></button>
							      <%--<span id="videoSwfButton"></span>--%>
							      <%--<button type="button" class="btn btn-default"><s:message code="upload"/></button>--%>
							      <%--<button class="btn btn-default" id="videoSwfCancel" type="button" onclick="videoSwfUpload.cancelQueue();" disabled><s:message code="cancel"/></button>--%>
						      </span>
                            </div>
                            <div id="videoSwfProgress"></div>
                            <script type="text/javascript">
                              $(function() {
                                Cms.f7.videolib("fLookBack","fLookBackName",{
                                  settings: {"title": "选择视频"}
                                });
                              });
                            </script>
                            <script type="text/javascript">
                              var videoSwfUpload = Cms.swfUploadVideo("fLookBack",{
                                jsessionid: "<%=request.getSession().getId()%>",
                                file_size_limit: "${GLOBAL.upload.videoLimit}",
                                file_types: "${GLOBAL.upload.videoTypes}"
                              });
                            </script>
                        </div>
                    </div>
                    </div>
                </div>

               <%-- <script type="text/javascript">
                    $(function () {
                        $("#select_1").on({
                            change: function (e) {
                                console.log();
                                // location.href=$(this).val();
                                var ri = $(this).val();
                                if (ri == 0) {
                                    var temp = "/cmscp/ext/livebroadcast/create.do?per=0"
                                } else if (ri == 1) {
                                    var temp = "/cmscp/ext/livebroadcast/create.do?per=1"
                                } else if (ri == 2) {
                                    var temp = "/cmscp/ext/livebroadcast/create.do?per=2"
                                }
                                location.href = temp;
                            }
                        })
                    })
                </script>--%>

                <%-----------------------------------------------------------[  按钮 保存 如下:  ]----------------------------------------------------------------------------------%>
                <div class="box-footer">
                    <button class="btn btn-primary" type="submit" onclick="$('#redirectLive').val('save');"><s:message code="save"/></button>
                    <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('list');"><s:message
                            code="saveAndReturn"/></button>
                    <c:if test="${oprt=='create'}">
                        <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('create');"><s:message
                                code="saveAndCreate"/></button>
                    </c:if>
                </div>
            </div>
        </form>
        <%-------------------------------------------------------[   播放地址  可以新增  删除  列表 ]-------------------------------------------------------------%>
        <%-------------------------------------------------------------------------------------------------------------------------%>
        <%------------------------------------------------------------------------------------------%>
        <form method="post">
            <div id="live_addAear" style="<c:if test="${oprt=='create'}">display: none;</c:if>">
                <div class="inls-opt" style="margin-bottom: 10px">
                    <shiro:hasPermission name="ext:livebroadcast:liveDelete">

                    <button class="btn btn-default" href="javascript:void(0);"
                            onclick=" return optMulti(this.form,'liveDelete.do?&stat=${stat}','确定要删除对应的地址!');">删除地址</button>
                    </shiro:hasPermission>

                    <shiro:hasPermission name="ext:livebroadcast:liveSave">
                    <button class="btn btn-default" href="javascript:void(0);"
                       onclick="return liveSave(this.form,'liveSave.do?&stat=${stat}&broadcastId=${bean.id}','确认创建直播地址?');"><s:message
                            code='addRow'/></button>
                    </shiro:hasPermission>
                    &nbsp;
                    <%--<a href="javascript:void(0);"  class="btn btn-default" type="button" onclick="Cms.moveTop('itemIds');" class="ls-opt"><s:message--%>
                            <%--code='moveTop'/></a>--%>
                    <%--<a href="javascript:void(0);" class="btn btn-default" type="button" onclick="Cms.moveUp('itemIds');" class="ls-opt"><s:message--%>
                            <%--code='moveUp'/></a>--%>
                    <%--<a href="javascript:void(0);" class="btn btn-default" type="button"  onclick="Cms.moveDown('itemIds');" class="ls-opt"><s:message--%>
                            <%--code='moveDown'/></a>--%>
                    <%--<a href="javascript:void(0);" class="btn btn-default" type="button" onclick="Cms.moveBottom('itemIds');" class="ls-opt"><s:message--%>
                            <%--code='moveBottom'/></a>--%>
                </div>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead>
                    <tr>
                        <th><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th><s:message code="operate"/></th>
                        <th>名称</th>
                        <th>输入地址</th>
                        <th>输出地址</th>
                        <th>创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="address" varStatus="status" items="${bean.livebroadcasts}">
                        <tr beanid="${address.id}">
                            <td align="center"><input type="checkbox" name="ids" value="${address.id}"/></td>
                            <td align="center">
                                <shiro:hasPermission name="ext:livebroadcast:liveEdit">
                                    <a   href="liveEdit.do?addressId=${address.id }&stat=${stat}"   class="ls-opt">指定直播记者</a>
                                </shiro:hasPermission>

                                <shiro:hasPermission name="ext:livebroadcast:liveDelete">
                                    <a href="liveDelete.do?ids=${address.id}&stat=${stat}" onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>
                                </shiro:hasPermission >
                            </td>
                            <td align="center"><c:out value="${address.user.username}"/></td>
                            <td align="center">
                                <f:textarea class="form-control"  value="${address.imputAddress}" maxlength="180" rows="5"/>
                            </td>
                            <td align="center">
                                <f:textarea class="form-control"  value="${address.outAddress}" maxlength="180" rows="5"/>
                            </td>
                            <td align="center"><fmt:formatDate value="${address.createTime}"
                                                pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</div>
</div>
</body>
</html>